Contents | Index | < Browse | Browse >

LETTERstrncmpULETTER Compares two strings, length-limited.

Overview
#include <string.h>

r = strncmp(s1,s2,n);

int r;
const char *s1;
const char *s2;
size_t n;

Portability
ANSI

Description
Compares the two strings char-by-char. In opposite to strcmp, it stops after "n" characters. If the strings are identically so far, strncmp returns zero. If the first different character in "s1" is lower than the corrospending character in "s2", it returns a value smaller than zero, and a value bigger than zero otherwise.

Returns
Zero, if the strings are identically, <0 if the first string is "smaller" than the second, >0 otherwise.

See also
strcmp